package com.xuecheng.content.convert;


import com.xuecheng.api.content.model.dto.CourseBaseDTO;
import com.xuecheng.api.content.model.vo.CourseBaseVo;
import com.xuecheng.content.entity.CourseBase;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

/***
 * po转 dto 数据 类
 */
@Mapper
public interface CourseBaseConvert {

    CourseBaseConvert INSTANCE = Mappers.getMapper(CourseBaseConvert.class);

    /**
     * po转dto
     * 两个类哪个变量名不同，需转换
     */
    @Mapping(source = "id", target = "courseBaseId")
    CourseBaseDTO entity2dto(CourseBase courseBase);

    /**
     * 多个变量转换方式
     */
        /*@Mappings(
                @Mapping(source="id",target="CourseBaseId"),
                @Mapping(source="name",target="userName")
        )*/

    /**
     * CourseBaseVo-->CourseBaseDTO
     *
     * @param courseBaseVo 接收前端传入类
     * @return CourseBaseDTO 给service层操作
     */
    CourseBaseDTO vo2dto(CourseBaseVo courseBaseVo);

    /**
     * po转dto
     * 两个类哪个变量名不同，需转换
     */
    @Mapping(source = "courseBaseId", target = "id")
    CourseBase dto2po(CourseBaseDTO courseBaseDTO);

    /**
     * Mapping 此注解只能用于单个数据
     * 集合方式需要依赖上面那个方法entity2dto
     */
    List<CourseBaseDTO> entitys2dtos(List<CourseBase> courseBases);

}